package com.shop.controller;

import com.shop.result.JsonResult;
import com.shop.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/userInfo")
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @RequestMapping("/getUserInfoByToken")
    @ResponseBody
    public JsonResult getUserInfoByToken(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult jsonResult = userInfoService.queryUserInfoByCondition(request,response);
        return jsonResult;
    }

    @RequestMapping("/addUserInfoByToken")
    @ResponseBody
    public JsonResult addUserInfoByToken(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult jsonResult = userInfoService.addUserInfoByToken(request,response);
        return jsonResult;
    }

    @RequestMapping("/updateUserInfoByToken")
    @ResponseBody
    public JsonResult updateUserInfoByToken(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult jsonResult = userInfoService.updateUserInfoByToken(request,response);
        return jsonResult;
    }

    @RequestMapping("/deleteUserInfoByToken")
    @ResponseBody
    public JsonResult deleteUserInfoByToken(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult jsonResult = userInfoService.deleteUserInfoByToken(request,response);
        return jsonResult;
    }
}
